<%@page import="org.prs.persistence.department.DepartmentPersistenceManager"%>
<%@page import="org.prs.persistence.UserLevelDatabasePersitenceManager"%>
<%@page import="org.prs.model.UserLevel"%>
<%@page import="java.util.List"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="org.prs.model.User"%>
<%@page import="org.apache.commons.validator.GenericValidator"%>
<%@page contentType="text/html"  language="java" %>
<%
            String userCreationMessage = (String) session.getAttribute("usercreationmsg");
            session.setAttribute("usercreationmsg", null);
            User loggedInUser = (User) session.getAttribute("loggedinuser");

            if (loggedInUser == null) {
                session.setAttribute("loginmsg", "<div id='loginmsg'>Please log in to use services</div>");
                response.sendRedirect("index.jsp");
            }
            UserLevelDatabasePersitenceManager persistUserLevel=new UserLevelDatabasePersitenceManager();
            List<UserLevel> levels=persistUserLevel.getAllUserLevels(0,persistUserLevel.getUserLevelCount() , "name");
            request.setAttribute("levels",levels);
            
            DepartmentPersistenceManager persistDepartment=new DepartmentPersistenceManager();
            request.setAttribute("departments", persistDepartment.getAllDepartments());
%>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta name="keywords" content="" />
        <meta name="description" content="" />
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>Patnership Record System</title>
        <link href="style.css" rel="stylesheet" type="text/css" media="screen" />

        <script type="text/javascript" src="js/menu.js">
        </script>
        <title>Welcome to Patnership Registration System</title>
        <link rel="SHORTCUT ICON" href="images/favicon.ico" />
        <link rel="stylesheet" type="text/css" href="css/menu/menu.css"/>
        <script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
        <script type="text/javascript" src="js/jquery-ui-1.8.10.custom.min.js"></script>
        <link rel="stylesheet" href="css/jquery/jquery-ui-1.8.10.custom.css" type="text/css" />
    </head>
    <body>
        <div id="wrapper">
            <div id="header">
                <div id="logo">
                    <h1><a href="#">Patnership Record System </a></h1>
                </div>
                <div id="menu">
                    <jsp:include page="includes/header.jsp"></jsp:include>
                </div>
            </div>
            <!-- end #header -->
            <div id="page">
                <div id="page-bgtop">
                    <div id="page-bgbtm">
                        <div id="content">
                            <form class='foorm' name='newMemberForm' id='newMemberForm' method='post' action='newmember'>
                                <%
                                            if (!GenericValidator.isBlankOrNull(userCreationMessage)) {
                                                out.println(userCreationMessage);
                                            }
                                %>
                                The fields marked with <font color='#ff0000'>*</font> are mandatory<br />
                                <table border='0' cellpadding='0' style='width: 100%;'>
                                    <tr>
                                        <td width='50%'><label><font color=#ff0000>*</font>First Name</label></td>
                                        <td width='50%'><input type='text' size='30' name='firstname' value='' id='firstname'/></td>
                                    </tr>
                                    <tr>
                                        <td width='50%'><label>Middle Name</label></td>
                                        <td width='50%'><input type='text' size='30' name='middlename' value='' id='middlename'/></td>
                                    </tr>
                                    <tr>
                                        <td width='50%'><label><font color=#ff0000>*</font>Last Name</label></td>
                                        <td width='50%'><input type='text' size='30' name='lastname' value='' id='lastname'/></td>
                                    </tr>
                                   <tr>
                                        <td width='50%'><label><font color=#ff0000>*</font>Gender</label></td>
                                        <td width='50%'><select name='gender' value='' id='gender'>
                                                <option value="Male">Male</option>
                                                <option value="Female">Female</option>
                                            </select></td>
                                    </tr>
                                    
                                    <tr>
                                        <td width='50%'><label><font color=#ff0000>*</font>Department</label></td>
                                        <td width='50%'><select name='department'  id='department'>
                                                <option value="">Select</option>
                                                <c:forEach var="department" items="${departments}">
                                                    <option value="${department.id}">${department.name}</option>
                                                </c:forEach>
                                            </select></td>
                                    </tr>
                                    
                                    <tr>
                                        <td colspan='2' width='100%'>
                                            <input type='submit' name='newusersubmit' id='newusersubmit' value='Register User'/>
                                        </td>
                                    </tr>
                                </table>
                            </form>
                        </div>
                        <!-- end #content -->
                        <div id="sidebar">
                            <!-- Navigation Start-->
                            <jsp:include page="includes/userProfile.jsp"/>

                            </div>

                        </div>
                        <!-- end #sidebar -->
                        <div style="clear: both;">&nbsp;</div>
                    </div>
                </div>
            </div>
            <!-- end #page -->
        </div>
        <div id="footer">
            <p>Copyright (c) 2011 prs.org. All rights reserved. Design by <a href="http://rwebs.javassl.com/">Java Servlet Systems Limited</a>.</p>
        </div>
        <!-- end #footer -->
    </body>
</html>
